PWD = $(shell pwd)
include ../Makefile.param
SRCS  := $(wildcard src/*.c)
SRCS  += $(wildcard src/common/*.c)
SRCS  += $(wildcard camera/src/*.c)
SRCS  += $(wildcard time_fun/src/*.c)
NFS_PATH := /home/hi3519a/Hi3519AV100_SDK_V2.0.1.0/osdrv/rootfs_scripts/rootfs/opt/mipi0

BIN_PATH := bin
BIN := $(PWD)/$(BIN_PATH)/mipi0imx291_h264rtsp
OBJ_PATH := $(PWD)/obj/
OBJ_SUB_PATH := $(OBJ_PATH)src
OBJ_SUB_PATH += $(OBJ_PATH)src/common
OBJ_SUB_PATH += $(OBJ_PATH)camera/src
OBJ_SUB_PATH += $(OBJ_PATH)time_fun/src


ALL_OBJ = $(patsubst %.c,%.o,$(SRCS))

ALL_OBJ_POS = $(addprefix $(OBJ_PATH),$(ALL_OBJ))

.PHONY : clean all
INC_FLAGS += -Isrc/common
INC_FLAGS += -Icamera/include
INC_FLAGS += -Itime_fun/include
INC_FLAGS += -Iinclude
CFLAGS += $(INC_FLAGS)

CFLAGS += $(COMM_INC)

MPI_LIBS += $(REL_LIB)/libhdmi.a
MPI_LIBS += $(REL_LIB)/libdsp.a

all: $(ALL_OBJ)
	@mkdir -p $(BIN_PATH)
	$(CC) $(CFLAGS) -lpthread -lm  -o $(BIN) $(ALL_OBJ_POS) $(MPI_LIBS) $(AUDIO_LIBA) $(SENSOR_LIBS) $(REL_LIB)/libsecurec.a 
	#cp $(BIN) $(NFS_PATH)

%.o:%.c
	@mkdir -p $(OBJ_SUB_PATH)
	$(CC) $(CFLAGS) -c $< -o $(OBJ_PATH)$@ -D HIMI_VIDEO #-D MOCK

clean:
	@rm -f $(ALL_OBJ)
	@rm -f $(BIN)
	@rm -f $(ALL_OBJ_POS)
	
cleanstream:
	@rm -f *.h264
	@rm -f *.jpg
	@rm -f *.mjp
	@rm -f *.mp4
